import 'package:json_annotation/json_annotation.dart';
// JsonSerializable json to dart
// {
//   "id": "chatcmpl-123",
//   "object": "chat.completion",
//   "created": 1677652288,
//   "choices": [{
//     "index": 0,
//     "message": {
//       "role": "assistant",
//       "content": "\n\nHello there, how may I assist you today?",
//     },
//     "finish_reason": "stop"
//   }],
//   "usage": {
//     "prompt_tokens": 9,
//     "completion_tokens": 12,
//     "total_tokens": 21
//   }
// }
part 'chat_message.g.dart';

@JsonSerializable()
class ChatCompletion {
  String id;
  String object;
  int created;
  List<Choice> choices;
  Usage usage;

  ChatCompletion(this.id, this.object, this.created, this.choices, this.usage);

  factory ChatCompletion.fromJson(Map<String, dynamic> json) =>
      _$ChatCompletionFromJson(json);

  Map<String, dynamic> toJson() => _$ChatCompletionToJson(this);
}
@JsonSerializable()
class Choice {
  int index;
  Message message;
  String finish_reason;

  Choice(this.index, this.message, this.finish_reason);

  factory Choice.fromJson(Map<String, dynamic> json) => _$ChoiceFromJson(json);

  Map<String, dynamic> toJson() => _$ChoiceToJson(this);
}
@JsonSerializable()
class Message {
  String role;
  String content;

  Message(this.role, this.content);

  factory Message.fromJson(Map<String, dynamic> json) =>
      _$MessageFromJson(json);

  Map<String, dynamic> toJson() => _$MessageToJson(this);
}
@JsonSerializable()
class Usage {
  int prompt_tokens;
  int completion_tokens;
  int total_tokens;

  Usage(this.prompt_tokens, this.completion_tokens, this.total_tokens);

  factory Usage.fromJson(Map<String, dynamic> json) => _$UsageFromJson(json);

  Map<String, dynamic> toJson() => _$UsageToJson(this);
}
@JsonSerializable()
class ChatMessage {
  String role;
  String content;

  ChatMessage(this.role, this.content);

  factory ChatMessage.fromJson(Map<String, dynamic> json) =>
      _$ChatMessageFromJson(json);

  Map<String, dynamic> toJson() => _$ChatMessageToJson(this);
}
